use std::error::Error;
use crossbeam::channel::{self, Sender};
use log::debug;

use crate::{server::Response, sql::parser::Token, storage::SendMessage};


pub fn execute(token: Token, sender: Sender<SendMessage>) -> Result<Response, Box<dyn Error>> {
    let (tx, rx)= channel::bounded::<Response>(1);
    sender.send(SendMessage::Request(token, tx))?;
    let response = rx.recv()?;
    Ok(response)
}